package com.commpany.servie.basic.promotion.service.write;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.commpany.jiedianqian.system.exception.BusinessException;
import com.commpany.jiedianqian.system.exception.SystemErrorEnum;
import com.commpany.servie.basic.promotion.api.write.PromotionWriteService;
import com.commpany.servie.basic.promotion.converter.PromotionConverter;
import com.commpany.servie.basic.promotion.business.write.promotion.PromotionWriteManage;
import com.commpany.servie.basic.promotion.model.dto.promotion.PromotionDTO;
@Slf4j
@Service("promotionWriteService")
public class PromotionWriteServiceImpl  implements PromotionWriteService {
	@Autowired
	private PromotionWriteManage promotionWriteManage;
	
	public int insertPromotionService( PromotionDTO inputDTO ){
	   try {
	       return promotionWriteManage.insertPromotionService(PromotionConverter.toPO(inputDTO));
	     } catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("系统异常", e);
			throw new BusinessException(SystemErrorEnum.SYSTEM_ERROR.getValue(), SystemErrorEnum.SYSTEM_ERROR.name());
		}
	}
    public int updatePromotionService( PromotionDTO inputDTO ){
       try {
           return promotionWriteManage.updatePromotionService(PromotionConverter.toPO(inputDTO));
        } catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("系统异常", e);
			throw new BusinessException(SystemErrorEnum.SYSTEM_ERROR.getValue(), SystemErrorEnum.SYSTEM_ERROR.name());
		}
    }
    public int deletePromotionService( PromotionDTO inputDTO ){
      try {
          return promotionWriteManage.deletePromotionService(PromotionConverter.toPO(inputDTO));
      } catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("系统异常", e);
			throw new BusinessException(SystemErrorEnum.SYSTEM_ERROR.getValue(), SystemErrorEnum.SYSTEM_ERROR.name());
		}
    }
}
	